package ro.gateway.aida.obj;

import java.util.Hashtable;


/**
 * Created by IntelliJ IDEA.
 * User: xblue
 * Date: Apr 15, 2003
 * Time: 11:28:03 PM
 * To change this template use Options | File Templates.
 */
public class OrganizationRole {
	private Integer id;
	private int harm_code = -1;
	private Hashtable names;

	public OrganizationRole() {
		this.names = new Hashtable();
	}

	public void setName(String lang, String name) {
		this.names.put(lang, name);
	}

	public String getName(String lang) {
		if (lang == null) {
			return null;
		}

		return (String) names.get(lang);
	}

	public void setHarm_code(int harm_code) {
		this.harm_code = harm_code;
	}

	public int getHarm_code() {
		return harm_code;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}


	public static final Integer FINANCING_ORG_ROLE = new Integer(1);
	public static final Integer BENEFICIARS_ORG_ROLE = new Integer(100);
	public static final Integer CONTRACTING_ORG_ROLE = new Integer(101);
	public static final Integer DONOR_ORG_ROLE = new Integer(102);
	public static final Integer DATASOURCE_ORG_ROLE = new Integer(103);
	public static final Integer NO_ROLE = new Integer(-1);


	// manarirea rolurilor pt. prezentare :D
	// poate ramane si pt. optimizare
	// vedem.
	// smike :P
	static Hashtable cachedRoles;

	static {


		cachedRoles = new Hashtable();

		OrganizationRole funding_role = new OrganizationRole();
		OrganizationRole benef_role = new OrganizationRole();
		OrganizationRole contr_role = new OrganizationRole();
		OrganizationRole donor_role = new OrganizationRole();
		OrganizationRole datasource_role = new OrganizationRole();

		OrganizationRole no_role = new OrganizationRole();
		cachedRoles.put(OrganizationRole.FINANCING_ORG_ROLE, funding_role);
		cachedRoles.put(OrganizationRole.BENEFICIARS_ORG_ROLE, benef_role);
		cachedRoles.put(OrganizationRole.CONTRACTING_ORG_ROLE, contr_role);
		cachedRoles.put(OrganizationRole.NO_ROLE, no_role);
		cachedRoles.put(OrganizationRole.DONOR_ORG_ROLE, donor_role);
		cachedRoles.put(OrganizationRole.DATASOURCE_ORG_ROLE, datasource_role);

		funding_role.setHarm_code(1);
		funding_role.setId(OrganizationRole.FINANCING_ORG_ROLE);
		funding_role.setName("ro", "Finantatori");
		funding_role.setName("en", "Financing");

		// non standard :-/
		benef_role.setHarm_code(-1);
		benef_role.setId(OrganizationRole.BENEFICIARS_ORG_ROLE);
		benef_role.setName("ro", "Beneficiari");
		benef_role.setName("en", "Beneficiars");

		// non standard :-/
		contr_role.setHarm_code(-1);
		contr_role.setId(OrganizationRole.CONTRACTING_ORG_ROLE);
		contr_role.setName("ro", "Institutii contractante");
		contr_role.setName("en", "Contracting institutions");

		// non standard :-/
		donor_role.setHarm_code(-1);
		donor_role.setId(OrganizationRole.DONOR_ORG_ROLE);
		donor_role.setName("ro", "Organizatie donor");
		donor_role.setName("en", "Donor organization");

		// non standard :-/
		datasource_role.setHarm_code(-1);
		datasource_role.setId(OrganizationRole.DATASOURCE_ORG_ROLE);
		datasource_role.setName("ro", "Organizatie - Sursa de date");
		datasource_role.setName("en", "Data Source organization");

		// reaaaallyyy non standard :-/
		no_role.setHarm_code(-1);
		no_role.setId(OrganizationRole.NO_ROLE);
		no_role.setName("ro", "Rol imaginar");
		no_role.setName("en", "Imaginary role");
	}

	public static OrganizationRole getCachedByLocalId(Integer local_role_id) {
		if (local_role_id == null) {
			return null;
		}
		OrganizationRole role = (OrganizationRole) cachedRoles.
			  get(local_role_id);
		return role;
	}


	public static void main(String[] args) {
		System.out.println("ding");
	}

}
